﻿@{
    ViewBag.Title = "网站管理平台_新建产品";
}

@section HeadContent
{
    <script type="text/javascript">
        var getProductContent = function () {
            var content = "";
            if (App.ProductContent.iframe != null) {
                content = App.ProductContent.iframe.dom.contentWindow.getContent();
            }
            App.Description.setValue(content);
        }
    </script>
}

@(Html.X().Viewport()
    .Layout("fit")
    .Items(
        Html.X().TabPanel().Items(
            Html.X().FormPanel()
                .ID("FormPanel1")
                .Layout("Column")
                .Title("产品信息")
                .Items(
                    Html.X().Panel()
                        .Border(false)
                        .ColumnWidth(0.5)
                        .Padding(5)
                        .Layout("form")
                        .Defaults(
                            Html.X().Parameter().Name("AnchorHorizontal").Value("90%")
                        )
                        .Items(
                            Html.X().TextField().ID("ProductName").FieldLabel("产品名称").AllowBlank(false).MaxLength(50),
                            Html.X().ComboBox().ID("ProdCataID").FieldLabel("所属产品目录").Editable(false)
                                .Store(Html.X().Store()
                                    .Model(Html.X().Model().IDProperty("ProdCataID")
                                        .Fields(
                                            new ModelField("ProdCataID", ModelFieldType.Int),
                                            new ModelField("ProdCataName")
                                        )
                                    )
                                    .Proxy(Html.X().AjaxProxy().Url(Url.Action("GetAllProductCata", "ProductCata")).Reader(Html.X().JsonReader().Root("data")))
                                )
                                .DisplayField("ProdCataName")
                                .ValueField("ProdCataID"),
                            Html.X().TextField().ID("ExpDate").FieldLabel("保质期").MaxLength(50),
                            Html.X().TextField().ID("Package").FieldLabel("包装规格").MaxLength(50),
                            Html.X().TextField().ID("StoreCondition").FieldLabel("贮存条件").MaxLength(50),
                            Html.X().FileUploadField().ID("ProductCover").FieldLabel("产品封面图").Icon(Icon.ImageAdd).ButtonText(""),
                            Html.X().Hidden().ID("Description")
                        ),
                    Html.X().Panel()
                        .Border(false)
                        .ColumnWidth(0.5)
                        .Padding(5)
                        .Layout("form")
                        .Defaults(
                            Html.X().Parameter().Name("AnchorHorizontal").Value("90%")
                        )
                        .Items(
                            Html.X().TextField().ID("ProductLevel").FieldLabel("等级").MaxLength(50),
                            Html.X().TextField().ID("UnitPrice").FieldLabel("价格").MaxLength(50),
                            Html.X().TextField().ID("Brand").FieldLabel("品牌"),
                                Html.X().TextField().ID("AppDomain").FieldLabel("功能"),
                            Html.X().NumberField().ID("SortNum").FieldLabel("排序序号").MinValue(0),
                            Html.X().ComboBox().ID("IsShow").FieldLabel("是否显示").Editable(false)
                                .Items(
                                    Html.X().ListItem().Text("隐藏").Value("0"),
                                    Html.X().ListItem().Text("显示").Value("1")
                                ).SelectedItems("1")
                        )
                )
                .TopBar(
                    Html.X().Toolbar().Items(
                        Html.X().Button().Text("保存").Icon(Icon.Disk)
                            .DirectEvents(de =>
                            {
                                de.Click.Action = "CreateProduct";
                                de.Click.EventMask.ShowMask = true;
                                de.Click.EventMask.Msg = "正在保存";
                                de.Click.Success = "ext.net.comjs.onSubmitSuccess";
                                de.Click.Failure = "ext.net.comjs.onSubmitFailure";
                                de.Click.IsUpload = true;
                            })
                            .Listeners(ls =>
                            {
                                ls.Click.Handler = "getProductContent(); return ext.net.comjs.onFormSubmit()";
                            })
                    )
                )
                .BottomBar(Html.X().StatusBar().DefaultText("Ready"))
                        .Listeners(ls => ls.ValidityChange.Handler = "ext.net.comjs.setFormStatusBar(this, valid)"),
            Html.X().Panel().ID("ProductContent").Title("产品描述").Loader(
                Html.X().ComponentLoader()
                    .Url(Url.Action("ProductDescription"))
                    .Mode(LoadMode.Frame)
                    .LoadMask(lm =>
                    {
                        lm.ShowMask = true;
                        lm.Msg = "加载中，请稍候...";
                    })
            )
        )
    )
)

